package com.superlight.designer.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Classname SwaggerConfig
 * @Description TODO
 * @Date 2021/5/10 11:17
 * @Created by leishihua
 */
@EnableSwagger2                // Swagger的开关，表示已经启用Swagger
@Configuration
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                // 自行修改为自己的包路径
                .apis(RequestHandlerSelectors.basePackage("com.superlight.designer"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("包装方案管理")
                .description("包装方案管理 API 1.0 操作文档")
                //服务条款网址
                .termsOfServiceUrl("https://www.baidu.com/")
                .version("1.0")
                .contact(new Contact("山蒲照明", "https://sso.super-lamps.com", "0573-59862"))
                .build();
    }
}
